<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>安装</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__STATIC__/res/layui/css/layui.css" media="all">
    <style>
        .right{
            color: #009688;
            font-weight: bold;
        }
        .wrong{
            color: #FF5722;
            font-weight: bold;
        }
    </style>
</head>
<body>
<div class="layui-container">
    <div class="layui-row">
        <div class="layui-col-md12">
           {include file='index/header'}
            <div class="environment">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                    <legend>运行环境检查</legend>
                </fieldset>
                <blockquote class="layui-elem-quote">请保证开启以下环境，否则运行程序会出现错误</blockquote>
                <table class="layui-table lay-even">
                    <colgroup>
                        <col width="150">
                        <col width="350">
                        <col>
                    </colgroup>
                    <thead>
                    <tr>
                        <th>配置</th>
                        <th>说明</th>
                        <th>是否支持</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach $extensions as $extension}
                    <tr>
                        <td>{$extension.name}</td>
                        <td>{$extension.desc}</td>
                        <td>
                            {if $extension.check}
                            <i class="layui-icon layui-icon-ok right"></i>
                            {else/}
                            <i class="layui-icon layui-icon-close wrong"></i>
                            {/if}
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>

                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                    <legend>目录权限检查</legend>
                </fieldset>
                <blockquote class="layui-elem-quote">请保证以下目录的校验，否则安装会出现错误</blockquote>
                <table class="layui-table lay-even">
                    <colgroup>
                        <col width="150">
                        <col width="350">
                        <col width="150">
                        <col width="150">
                        <col width="150">
                        <col>
                    </colgroup>
                    <thead>
                    <tr>
                        <th>目录</th>
                        <th>说明</th>
                        <th>权限要求</th>
                        <th>可读</th>
                        <th>可写</th>
                        <th>校验</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach $dirs as $dir}
                    <tr>
                        <td>{$dir.name}</td>
                        <td>{$dir.desc}</td>
                        <td>{$dir.permission}</td>
                        <td>
                            {if $dir.read}
                            <i class="layui-icon layui-icon-ok right"></i>
                            {else/}
                            <i class="layui-icon layui-icon-close wrong"></i>
                            {/if}
                        </td>
                        <td>
                            {if $dir.write}
                            <i class="layui-icon layui-icon-ok right"></i>
                            {else/}
                            <i class="layui-icon layui-icon-close wrong"></i>
                            {/if}
                        </td>
                        <td>
                            {if $dir.check}
                            <i class="layui-icon layui-icon-ok right"></i>
                            {else/}
                            <i class="layui-icon layui-icon-close wrong"></i>
                            {/if}
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
            </div>
            <div>
                <button type="button" class="layui-btn next">继续安装</button>
            </div>
        </div>
    </div>
    {include file='index/footer'}
</div>

<script src="__STATIC__/res/layui/layui.js"></script>
<script>
    var CHECK_DIR_ENVIRONMENT_URL='{:url("index/checkDirsAndEnvironment")}';
    var GO_SETTING_URL='{:url("index/setting")}';
    layui.config({
        base: '__STATIC__/res/' //静态资源所在路径
    }).use(['index'],function(){
        var $ = layui.$;
        $('.next').click(function(){

            $.ajax({
                method: 'post',
                url: CHECK_DIR_ENVIRONMENT_URL,
                success: function (res) {
                    if (res.result.status) {
                        layer.msg(res.result.msg, {
                            offset: '15px'
                            , icon: 2
                            , time: 1000
                        });
                        return
                    }

                    location.href = GO_SETTING_URL;
                    // layer.msg(res.result.msg, {
                    //     offset: '15px'
                    //     , icon: 1
                    //     , time: 1000
                    // });
                }
            });
        })
    });
</script>
</body>
</html>